package org.pcorp.battlespace.construction.ui.onglets;

import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;

import javax.swing.JPanel;

import org.pcorp.battlespace.construction.modele.VaisseauCstr;
import org.pcorp.battlespace.construction.ui.Principal;
import org.pcorp.battlespace.construction.ui.sub.structure.GeneralUi;
import org.pcorp.battlespace.construction.ui.sub.structure.KfUi;
import org.pcorp.battlespace.construction.ui.sub.structure.PropulsionUi;
import org.pcorp.battlespace.construction.ui.sub.structure.StructureUi;
import org.pcorp.battlespace.construction.ui.tools.GeneralRuleUi;

public class OngletStructureUi extends GeneralRuleUi {
	private static final long serialVersionUID = 3658339586354814436L;
	private GeneralUi general;
	private KfUi kf;
	private PropulsionUi propulsion;
	private StructureUi structure;
	
	public OngletStructureUi(Principal p) {
		super(p);
		general = new GeneralUi(p);
	    kf = new KfUi(p);
	    propulsion = new PropulsionUi(p);
	    structure = new StructureUi(p);
	    
		setLayout(new GridBagLayout());
		GridBagConstraints gbc = new GridBagConstraints();
		
		gbc.gridx = gbc.gridy = 0;
	    gbc.gridwidth = gbc.gridheight = 1;
	    gbc.weightx = 1;
	    gbc.weighty = 0;
	    
	    gbc.anchor = GridBagConstraints.PAGE_START;
	    gbc.fill = GridBagConstraints.HORIZONTAL;
	    gbc.gridx = 0;
	    
	    gbc.gridy = 0;
	    add(general, gbc);
	    //gbc.weighty = 1; // permet de caler le composant en haut en lui attribuant toute la place restante dispo
	    gbc.gridy = 1;
	    add(kf, gbc);
	    
	    gbc.gridy = 2;
	    add(propulsion, gbc);
	    

	    gbc.gridy = 3;
	    add(structure, gbc);
	    
	    JPanel pVide = new JPanel();
	    gbc.gridy = 4;
	    gbc.anchor = GridBagConstraints.PAGE_END;
	    gbc.weighty = 1; // permet de caler le composant en haut en lui attribuant toute la place restante dispo
	    add(pVide, gbc);
	}

	public GeneralUi getGeneral() {
		return general;
	}

	public void setGeneral(GeneralUi general) {
		this.general = general;
	}

	public KfUi getKf() {
		return kf;
	}

	public void setKf(KfUi kf) {
		this.kf = kf;
	}

	@Override
	public void updateDisplay(VaisseauCstr vaiss) {
		general.updateDisplay(vaiss);
		kf.updateDisplay(vaiss);
		propulsion.updateDisplay(vaiss);
		structure.updateDisplay(vaiss);
		
	}

	@Override
	public void updateModel(VaisseauCstr vaiss) {
		general.updateModel(vaiss);
		kf.updateModel(vaiss);
		propulsion.updateModel(vaiss);
		structure.updateModel(vaiss);
	}
}
